package leecode

import "math"

func majorityElementLM(nums []int) (result int) {
	result = -1
	count := math.MinInt64
	hashMap := make(map[int]float64)
	for i := 0; i < len(nums); i++ {
		hashMap[nums[i]]++
		if hashMap[nums[i]] >= float64(len(nums))/2 {
			temp := hashMap[nums[i]]
			if temp > float64(count) {
				count = int(temp)
				result = nums[i]
			}
		}
	}
	return result
}
